home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boss.arc / BOSSDEMO.C next >
Text File  |  1987-06-04  |  11KB  |  359 lines

  1. /*
  2. ** Demo for The Window Boss
  3. **
  4. ** Copyright (c) 1985 - Philip A. Mongelluzzo
  5. ** All rights reserved.
  6. **
  7. */
  8.  
  9. #include "windows.h"                    /* windows header file */
  10.  
  11. #if DLC
  12. int _stack = 8192;                      /* Datalight C */
  13. #endif
  14.  
  15. #define TRUE 1                          /* a few equates */
  16. #define FALSE 0
  17.  
  18.   struct mitem {                        /* menu item template */
  19.     int r;                              /* row */
  20.     int c;                              /* col */
  21.     char *t;                            /* text */
  22.     int rv;                             /* return value */
  23.   };
  24.  
  25.   struct pmenu {                        /* popup menu structure */
  26.     int fm;                             /* first menu item index */
  27.     int lm;                             /* last menu item index */
  28.     struct mitem scrn[25];              /* a bunch of menu items */
  29.   };
  30.  
  31. main(argc,argv)
  32. int argc;
  33. char *argv[];
  34. {
  35. WINDOWPTR w0, w2, w3;                   /* a few windows */
  36. WINDOWPTR tw1, tw2, tw3;                /* and a few more */
  37.  
  38. WINDOWPTR qpopup();                     /* function returns WP */
  39. int i,j,k;                              /* scratch integers */
  40. int watrib,batrib;                      /* scratch atributes */
  41. int rv;                                 /* for popup */
  42.  
  43.   static struct pmenu m1 = {
  44.     00, 00, {
  45.     01, 02, "Presenting", 0,
  46.     00, 00, "",99 }
  47.   };
  48.  
  49.   static struct pmenu m2 = {
  50.     00, 00, {
  51.     01, 02, "The", 0,
  52.     03, 02, "W i n d o w   B O S S", 0,
  53.     05, 02, "Fast - Easy - Windows", 0,
  54.     07, 02, "for the C Language", 0,
  55.     00, 00, "",99 }
  56.   };
  57.  
  58.   static struct pmenu intelc = {
  59.     02, 06, {
  60.     01, 02, "         Intellicom", 0,
  61.     02, 02, "        Quick - Help", 0,
  62.     04, 05, "_ General Information", 1,
  63.     05, 05, "_ Terminal Mode Options", 2,
  64.     06, 05, "_ XMODEM File Send", 3,
  65.     07, 05, "_ XMODEM File Receive", 4,
  66. #if MSC | DLC
  67.      8, 05, "_ CompuServe Exec Mode", 5,
  68. #else
  69.     08, 05, "_ CompuServe Exec Mode", 5,
  70. #endif
  71.     10, 02, "Press: ESC to quit or Cursor", 0,
  72.     11, 02, " Keys to Position Cursor then", 0,
  73.     12, 02, " press RETURN for MORE info.", 0,
  74.     00, 00, "",99 }
  75.   };
  76.  
  77.   if(argc > 1) wn_dmaflg=FALSE;         /* for testing bios access */
  78.   w0 = wn_save(0,0,0,78,23);            /* save entry screen */
  79.   if(!w0) exit();                       /* less than graceful exit */
  80.  
  81.   batrib = v_setatr(WHITE,BLACK,0,BOLD);/* set border atrib */
  82.   watrib = v_setatr(WHITE,RED,0,0);     /* make it american */
  83.   w2 = qpopup(0,0,0,16,3,watrib,batrib,&m1);
  84.   for(i=1; i<11; i++)                   /* move it into place */
  85.     w2 = wn_move(w2, i, i*2); 
  86.  
  87.   hiber(1);                             /* wait 1 second (aprx) */
  88.  
  89.   batrib = v_setatr(RED,WHITE,0,0);     /* set border atrib */
  90.   watrib = v_setatr(BLUE,WHITE,0,0);    /* make this american too */
  91.   w3 = qpopup(0,0,0,30,9,watrib,batrib,&m2);
  92.   for(i=1; i<8; i++)                    /* move into place */
  93.     w3 = wn_move(w3,i,6*i);             /* move into place */
  94.  
  95.   hiber(7);                             /* reading time.. */
  96.  
  97.   wn_close(w3);                         /* close a couple */
  98.   hiber(1);
  99.   wn_close(w2);
  100.   hiber(1);
  101.  
  102.   watrib = v_setatr(WHITE,BLACK,0,BOLD);
  103.   for(i=0; i<25; i++) {                 /* build the back drop */
  104.     v_locate(0,i,0);                    /* position cursor */
  105.     v_wca(0, 0xb0, watrib, 80);         /* the fast way */
  106.   }
  107.   v_hidec();                            /* hide the cursor */
  108.  
  109.   watrib = v_setatr(WHITE,BLACK,0,0);   /* window attribute */
  110.   batrib = v_setatr(BLUE,WHITE,0,0);    /* border attribute */
  111.   w3 = wn_open(800,2,9,60,19,watrib,batrib);
  112.   w3->bstyle |= BOLD;                   /* toggle bold on then off */
  113.   wn_title(w3," The Window BOSS for C ");
  114.   w3->bstyle ^= BOLD;
  115.   wn_puts(w3,1,1,"The Window BOSS puts YOU in control of the most important");
  116.   wn_puts(w3,2,1,"sophisticated state-of-the-art screen handing techniques ");
  117.   wn_puts(w3,3,1,"available today.  Pop-up windows, pull-down menus, status ");
  118.   wn_puts(w3,4,1,"lines and context sensitive help functions are a breeze ");
  119.   wn_puts(w3,5,1,"to implement!  Your program automatically senses the ");
  120.   wn_puts(w3,6,1,"video card installed and ALL your video output takes ");
  121.   wn_puts(w3,7,1,"place with no snow, no flicker, and no delay. But best of");
  122.   wn_puts(w3,8,1,"all, The Window BOSS is SHAREWARE software!  ");
  123.   wn_puts(w3,9,1," ");
  124.   wn_puts(w3,10,1,"The Window BOSS is available for the Lattice, Microsoft,  ");
  125.   wn_puts(w3,11,1,"Datalight, Borland, and Computer Innovations Compilers.");
  126.   wn_puts(w3,12,1,"Registered users receive complete documentation, all");
  127.   wn_puts(w3,13,1,"source code, and complete libaries for all memory models.");
  128.   wn_puts(w3,14,1," ");
  129.   wn_puts(w3,15,1,"I challenge you to compare: The Window BOSS is faster");
  130.   wn_puts(w3,16,1,"and easier to use, than most commercial products on the");
  131.   wn_puts(w3,17,1,"market today!");
  132.   hiber(30);
  133.  
  134.   watrib = v_setatr(WHITE,BLUE,0,0);    /* window attribute */
  135.   batrib = v_setatr(RED,WHITE,0,BOLD);  /* border attribute */
  136.   w2 = wn_open(0,5,5,50,10,watrib,batrib);
  137.   if(!w2) exit();                       /* yes.. it should be better */
  138.   wn_puts(w2,0,0," Simple text output is very fast");
  139.   wn_puts(w2,1,0," and snow free.");
  140.   wn_puts(w2,3,0," Watch this....");
  141.   hiber(3);
  142.   wn_clr(w2);                           /* clear it then fill it */
  143.   for(i=0; i<10; i++)
  144.     wn_puts(w2,i,0," Very fast screen output - no snow!");
  145.   hiber(5);
  146.   wn_clr(w2);                           /* do it again */
  147.   for(i=0; i<10; i++)
  148.     wn_puts(w2,i,0," Another window full of fast text.");
  149.   hiber(5);
  150.  
  151.   wn_clr(w2);
  152.   wn_printf(w2," The BOSS also supports a printf function!\n");
  153.   wn_printf(w2," Its as simple as:\n\n");
  154.   wn_printf(w2," \twn_printf(wn,\"%%d\\n\",i);\n\n");
  155.   wn_printf(w2," to print a value in a window.\n\n");
  156.   wn_printf(w2," Scrolling works too\n");
  157.   wn_printf(w2," Lets count (slowly) to 10...\n");
  158.   wn_sync(w2, TRUE);
  159.   hiber(10);
  160.   for(i=1;i<11;i++) {
  161.     wn_printf(w2," The count is: %d\n", i);
  162.     nap(5);
  163.   }
  164.   wn_printf(w2," Ok, lets see what it looks like at\n");
  165.   wn_printf(w2," full speed.. (counting to 25)\n");
  166.   hiber(5);
  167.   for(i=1;i<26;i++)
  168.     wn_printf(w2," The count is: %d\n", i);
  169.   hiber(5);                             /* reading time */
  170.   wn_sync(w2, FALSE);
  171.   v_hidec();
  172.  
  173.   wn_clr(w2);
  174.   wn_putsa(w2,0,0," Full color support is provided.",WHITE<<4);
  175.   for(i=1; i<6; i++)
  176.     wn_putsa(w2,i,0, " Add a little color to your life.",WHITE<<4|i);
  177.   wn_putsa(w2,6,0," As is window movement....watch...",WHITE<<4|BLACK);
  178.   hiber(5);
  179.  
  180.   for(i=0; i<13; i++)                   /* move the window around */
  181.     w2 = wn_move(w2, i, i*2); 
  182.   hiber(5);
  183.   wn_printf(w2,"\n Lets put it back where we started...\n");
  184.   hiber(3);
  185.   w2 = wn_move(w2,5,5); 
  186.   wn_printf(w2," Now, lets add a title to our window!\n");
  187.   hiber(3);
  188.   w2->bstyle |= BOLD;
  189.   wn_title(w2," Pretty Powerful Stuff ");
  190.   w2->bstyle ^= BOLD;
  191.   hiber(5);
  192.  
  193. /* ============================= Tiled Window Stuff ===================== */
  194.  
  195.   wn_printf(w2," Tiled windows are supported\n");
  196.   wn_printf(w2," Lets add three.\n");
  197.   hiber(5);
  198.  
  199.   wn_sbit=FAST;
  200.   wn_blank=FALSE;
  201.   tw1 = wn_open(0,3,5,40,10, RED<<4|YELLOW|BOLD, RED<<4|WHITE|BOLD);
  202.   wn_sync(tw1,TRUE);
  203.   wn_printf(tw1,"ONE\n");
  204.   tw2 = wn_open(0,6,8,40,10, BLUE<<4|WHITE|BOLD, BLUE<<4|GREEN|BOLD);
  205.   wn_sync(tw2,TRUE);
  206.   wn_printf(tw2,"TWO\n");
  207.   tw3 = wn_open(0,9,11,40,10,GREEN<<4|WHITE|BOLD, GREEN<<4|WHITE|BOLD);
  208.   wn_sync(tw3,TRUE);
  209.   wn_printf(tw3,"THREE\n");
  210.   wn_printf(tw3," Press a key and watch TWO move\n");
  211.   wn_printf(tw3," To the top!!\n");
  212.   v_getch();
  213.  
  214.   wn_activate(tw2);
  215.   wn_printf(tw2," Press a key and watch THREE move\n");
  216.   wn_printf(tw2," To the top!!\n");
  217.   v_getch();
  218.   wn_activate(tw3);
  219.   wn_printf(tw3," Press a key and watch ONE move\n");
  220.   wn_printf(tw3," To the top!!\n");
  221.   v_getch();
  222.   wn_activate(tw1);
  223.  
  224.   wn_printf(tw1, " Ok..Press a key\n");
  225.   wn_printf(tw1, " and we will continue with the show!");
  226.   v_getch();
  227.  
  228.   wn_close(tw1);
  229.   wn_close(tw3);
  230.   wn_close(tw2);
  231.   wn_sbit=SLOW;
  232.   wn_blank=TRUE;
  233.  
  234. /* ========================= End Tiled Stuff ============================ */
  235.  
  236.   wn_clr(w2);
  237.   wn_printf(w2," Popup Menus are a breeze.\n\n");
  238.   wn_printf(w2," Watch....");
  239.   hiber(2);
  240.  
  241.   help_init("intelc");                  /* init help function */
  242.   do {
  243.     rv = popup(0,0,0,33,14, WHITE<<4|BLACK, BLUE<<4|WHITE, &intelc,FALSE);
  244.  
  245.     switch (rv) {                       /* dispatch */
  246.       case 1:
  247.         help("%general information\r\n");
  248.         break;
  249.       case 2:
  250.         help("%terminal\r\n");
  251.         break;
  252.       case 3:
  253.         help("%checksum xmit1\r\n");
  254.         break;
  255.       case 4:
  256.         help("%checksum recv1\r\n");
  257.         break;
  258.       case 5:
  259.         help("%cistty1\r\n");
  260.         break;
  261.       case 99:
  262.       default:
  263.         break;
  264.     }
  265.   } while(rv !=99);
  266.  
  267.   wn_clr(w2);                           /* clear the window */
  268.   w2->bstyle |= BOLD;                   /* toggle bold on then off */
  269.   wn_title(w2," The Window BOSS for C ");
  270.   w2->bstyle ^= BOLD;
  271.   wn_printf(w2,"\n\n  The following is a quick summary\n");
  272.   wn_printf(w2,"  of SOME of the functions available...");
  273.   hiber(4);
  274.  
  275.   help("%bossinfo\r\n");                /* provide some details */
  276.  
  277.   wn_clr(w2);                           /* and now the credits */
  278.   wn_printf(w2,"\n\n\n");
  279.   wn_printf(w2,"                  The Window BOSS\n");
  280.   wn_printf(w2,"                Copyright (c) 1985\n");
  281.   wn_printf(w2,"              Philip  A. Mongelluzzo\n");
  282.   wn_printf(w2,"                 273 Windy Drive\n");
  283.   wn_printf(w2,"              Waterbury, Conn  06705\n");
  284.  
  285.   wn_printf(w2,"\n\t\t\t\tThats all folks...\n\n");
  286.  
  287.   hiber(10);                            /* all done ! */
  288.   wn_close(w2);
  289.   wn_close(w3);
  290.   wn_restore(w0);
  291. }
  292.  
  293. nap(ticks)                              /* sleep a few clock ticks */
  294. int ticks;
  295. {
  296. int tc;
  297. int ts, te;
  298.  
  299. #if BORLAND | MSCV3 | MSCV4             /* Borland, MSC */
  300.   ts = peek(0x40,0x6c);
  301.   for(tc=0; tc<ticks; ) {
  302.     if(chkesc()) return;
  303.     te = peek(0x40,0x6c);
  304.     if(ts == te) continue;
  305.     tc++;
  306.     ts = te;
  307.   }
  308. #endif
  309. #if CI86                                /* Computer Innovations, MWC */
  310.   ts = peek(0x6c,0x40);
  311.   for(tc=0; tc<ticks; ) {
  312.     if(chkesc()) return;
  313.     te = peek(0x6c,0x40);
  314.     if(ts == te) continue;
  315.     tc++;
  316.     ts = te;
  317.   }
  318. #endif                                  /* lattice and the rest */
  319. #if LC2 | LC3 | DLC 
  320.   peek(0x40, 0x6c, &ts, 2);
  321.   for(tc=0; tc<ticks; ) {
  322.     if(chkesc()) return;
  323.     peek(0x40, 0x6c, &te, 2);
  324.     if(ts == te) continue;
  325.     tc++;
  326.     ts = te;
  327.   }
  328. #endif
  329. }
  330.  
  331. hiber(seconds)
  332. int seconds;
  333. {
  334.   nap(seconds * 18);
  335. }
  336.  
  337. chkesc()                                /* check for ESC while napping */
  338. {
  339. int c;
  340.  
  341.   if(v_kstat()) {
  342.     c=v_getch() & 0x7f;
  343.     switch(c) {
  344.       case ESC:
  345.         return(TRUE);
  346.       case ETX:
  347.         v_cls(7);
  348.         v_locate(0,0,0);
  349.         exit(0);
  350.       default:
  351.         break;
  352.     }
  353.   }
  354.   return(FALSE);
  355. }
  356.  
  357. /* End */
  358.  
  359.